<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/includes.jsp" %>
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>角色管理</title>
	<!-- import css and js --> 
	<%@ include file="/common/metaInput.jsp" %>  
<script type="text/javascript">

var rolemenujson =${rolemenujson};
$(function(){
	
	$("#inputForm").validate({			   
		onsubmit: true,
		 /*执行ajaxsubmit  */ 
	    submitHandler: function(editform) {
	            
	        //alert(jsonInfo); 
	        try{			    		
	            url =  "${ctx}/security/rolemenuplace/save.do";
	            var api = frameElement.api;
	        	var W = api.opener;
	        
	        
	            getReturnMessage(url,"inputForm","");	
	        }catch(e){alert(e)}
	    }
	 }
	);

	var g=$("#tree1").ligerTree({  
		 //url: '${ctx}/security/rolemenuplace/tree.do?userid=${param.userid}',
		 data:rolemenujson,
		 nodeWidth: 115,
		 checkbox: true,
	     slide: false,
	     treeLine:false,
	     onClick:function(node){
	    	
	     },
	     onAfterAppend:function(parentNode, newdata){
	    	 //var manager = $("#tree1").ligerGetTreeManager(); 
	    	 //<c:forEach items='${list}' var='item'>
	    	 //	manager.selectNode("${item.organizationid}");
	 		//</c:forEach>
	     }
	 });
});
function submitForm(param){
	var manager = $("#tree1").ligerGetTreeManager(); 
	var data=manager.getChecked();
	var i=0;
	var meunid=null;
	$(data).each(function() {
		if(i==0){
			meunid=this.data.id;
		}else{
			meunid+=","+this.data.id;
		}
		i++;
	});
    //设置ajax全局同步
	jQuery.ajaxSettings.async = false;
	$("#meunid").val(meunid);
  	$("#submitFlag").val(param);
    $("#inputForm").submit();
 }	


		
	
</script>

</head>

<body>

<form id="inputForm" action="" method="post">
<input type="hidden" id="id" name="id" value="${id}"/>

<input type="hidden" name="meunid" id="meunid" value=""/>
<div id="layout1">
            <div position="left" title="菜单管理">
            <div style="height:470px;width:98%; float:left;overflow:auto;  ">
   				 <ul id="tree1"></ul>
    		</div> 
            </div>
        </div>
         <div class="formBar">
	        <ul>
		       <li><div class="buttonActive"><div class="buttonContent"><button type="button" id="save" onclick="submitForm(1)">保存</button></div></div></li>
		       <li><div class="button"><div class="buttonContent"><button type="button" class="print" onclick="CloseDialog()">关闭</button></div></div></li>
	        </ul>
        </div>    
    </div>
</form>
</body>
</html>
